{%
  if groups['pxc'] is defined
    and groups['pxc'] is truthy
%}
upstream mysql {
    least_conn;
    zone          upstream_dynamic 64k;
{% for server in groups['pxc'] %}
    server        {{ server }}:{{ pxc_port | default('3306') }};
{% endfor %}
}

server {
    listen        {{ pxc_port | default('3306') }};
    proxy_pass    mysql;
    health_check;
}
{% endif %}